<template>
	<view class="page-content bg-white">
		<u-navbar title="商品详情" :autoBack="true" :bgColor="theme_color" :titleStyle="{color:'#ffffff'}"
			leftIconColor="#ffffff">
			<view class="u-nav-slot" slot="left">
				<u-icon name="arrow-left" size="19" color="#ffffff"></u-icon>
				<u-line direction="column" :hairline="false" length="16" margin="0 8px" color="#ffffff"></u-line>
				<u-icon name="home" size="20" color="#ffffff" @click.stop="onToHomePage"></u-icon>
			</view>
		</u-navbar>
		<view class="goods-info" :style="'margin-top:' + navH + 'px;'">
			<view class="goods-box">
				<!-- 轮播图 :autoplay="false" -->
				<swiper :current="mode_current" :indicator-dots="true" :autoplay="false" :interval="500" :duration="500"
					style="height: 700rpx;">

					<swiper-item v-if="goodsInfo.goods_video" class="img-box">
						<video :src="goodsInfo.goods_video" controls></video>
					</swiper-item>

					<view v-if="goodsInfo.img_gallery" v-for="(value,i) in goodsInfo.img_gallery" :key="i">
						<swiper-item class="img-box">
							<image :src="value.img_original" :data-src="value.img_original" @tap="previewImage"
								mode="aspectFit">
							</image>
						</swiper-item>
					</view>
				</swiper>
				<u-skeleton rows="5" :loading="sek_loading" :animate="true"></u-skeleton>
				<view class="goods-name acea-row row-between u-skeleton">
					<view style="font-size: 16px;font-weight: 700;word-break: break-all;">
						{{goodsInfo.goods_name}}
					</view>
					<view class="iconfont icon-fenxiang" @click="shareClick" style="color: #515151;font-size: 20px;">
					</view>
				</view>
				<view class="goods-name u-skeleton" style="padding-top: 10rpx;">
					<block v-if="!isLogin">
						<text class="txt-price">
							零售价￥{{shop_price}}
						</text>
						<text class="txt-unit">
							/{{goodsInfo.unit}}
						</text>
					</block>
					<block v-else>
						<text class="txt-price">
							VIP￥{{vip_price}}
						</text>
						<text class="txt-unit">
							/ {{goodsInfo.unit}}
						</text>
					</block>
				</view>
				
				<view class="goods-name u-skeleton" style="padding-top: 0rpx;">
					<text class="txt-old">市场价&ensp;:</text>
					<text class="txt-oldprice">
						￥{{goodsInfo.market_price}}
					</text>
				</view>

				<view class="fs-14" style="padding: 10px 15px;">
					{{goodsInfo.goods_brief}}
				</view>

				

				<view class="goods-name acea-row row-between" style="margin-bottom: 10px;">
					<view class="fs-12" style="background-color: red;color: white;width: fit-content;padding: 2px 5px;"
						v-if="goodsInfo.sdg_id == 0" @click="posterGet()">
						预估分享佣金:{{goodsInfo.share_money}}元
					</view>
					<view class="fs-12"
						style="background-color: #FEF8EA;color: #BC7D63;width: fit-content;padding: 2px 5px;" v-else
						@click="posterGet()">
						分销预估佣金:￥{{goodsInfo.yjpt_price}}
					</view>
					<view v-if="goodsInfo.sdg_id > 0" @click="addUp(goodsInfo.sdg_id)" class="fs-12">
						+加入分销
					</view>
				</view>

				<!-- 库存 -->
				<view class="u-skeleton acea-row row-middle fs-14" style="padding: 0px 20px 10px;">
					<view style="margin-right: 40rpx;color: #82848f;">库存</view>
					<view style="color: darkgray;">{{goodsInfo.goods_number}}</view>
				</view>

				<u-gap height="5" bgColor="#F9F9F9"></u-gap>
				<!-- 规格选购 -->
				<view class="padding10 acea-row row-middle row-between fs-14" style="padding: 10px 20px;"
					@click="showTip==true?addBuyCar():showMode()">
					<view style="margin-right: 40rpx;color: #82848f;">规格选购</view>
					<view class="iconfont icon-jiantou" style="color: #7a7a7a;font-size: 14px;"></view>
				</view>

				<u-gap height="5" bgColor="#F9F9F9"></u-gap>
				<!--产品参数 -->

				<!-- 关联配件 -->
				<view v-if="goods_link_2.length > 0" style="padding: 10px 20px;">
					<view class="acea-row row-middle row-between" @click="goodsGroupBuy()">
						<veiw class="fs-14" style="color: darkgray;">配件选购</veiw>
						<veiw class="fs-14" style="color: darkgray;">批量购买</veiw>
					</view>
					<scroll-view scroll-x="true" @scrolltolower="addGoodLink2" lower-threshold='10px'
						style="white-space: nowrap;display: flex;">
						<view v-for="(item,i) in goods_link_2" :key="i" @click="toGoodsDetailGroup(item)">
							<image :src="item.thumb_url" style="width: 100px;height: 100px;"></image>
							<view class="fs-14 line1" style="padding: 5px 0;">{{item.goods_name}}</view>
							<view class="fs-12">￥{{item.shop_price}}</view>
						</view>
					</scroll-view>
				</view>
				
				<!--关联商品 -->
				<view v-if="goods_link.length > 0" style="padding: 10px 20px;">
					<view class="fs-14" style="color: darkgray;">
						关联商品
					</view>
					<scroll-view scroll-x="true" @scrolltolower="addgoodslink" lower-threshold='10px'
						style="white-space: nowrap;display: flex;">
						<view v-for="(item,i) in goods_link" :key="i" @click="toGoodsDetail(item)"
							style="width: 100px;display: inline-block;margin-right: 10px;">
							<image :src="item.goods_thumb" style="width: 100px;height: 100px;"></image>
							<view class="fs-14 line1" style="padding: 5px 0;">{{item.goods_name}}</view>
							<view class="fs-12">VIP ￥{{item.vip_price}}</view>
						</view>
					</scroll-view>
				</view>
			</view>
		</view>

		<view class="product-intro">
			<view class="title fs-16 fw-bolder">产品介绍</view>
			<view class="padding20">
				<view class="acea-row" v-if="goodsInfo.brand_name != null">
					<view class="fs-14">
						品牌名称
					</view>
					<view style="padding-left:10rpx" class="fs-14">
						{{goodsInfo.brand_name}}
					</view>
				</view>
				<view class="acea-row">
					<view style="text-align: center;" class="fs-14">
						商品编号
					</view>
					<view style="padding-left:10rpx" class="fs-14">
						{{goodsInfo.goods_sn}}
					</view>
				</view>
				<view style="display: flex;flex-direction: row;">
					<view style="text-align: center;" class="fs-14">
						上架时间
					</view>
					<view style="padding-left:10rpx" class="fs-14">
						{{goodsInfo.add_time==null?'':goodsInfo.add_time.slice(0,10)}}
					</view>
				</view>
			</view>


			<view style="width: 100%;  padding-bottom: 200upx; ">
				<bctos-rich-text :nodes="goodsInfo.goods_desc"></bctos-rich-text>
				<!-- <view v-html="goodsInfo.goods_desc"></view> -->
			</view>

		</view>

		<view class="footer acea-row row-middle ">
			<!-- 	<view class="item">
				<view class="iconfont icon-dianpu" @click="stroreTo()"></view>
				<view class="text" @click="stroreTo()">
					店铺
				</view>
			</view> -->
			<!-- <view class="item">
				<view class="iconfont icon-kefu"></view>
				<u-button open-type="contact">客服</u-button>
			</view> -->
			<view class="acea-row row-around" style="flex: 1;">
				<view class="item">
					<view class="iconfont icon-shoucang" v-if="goodsInfo.is_collect == 0" @click="loveGoogs()"></view>
					<view class="iconfont icon-shoucang1" v-if="goodsInfo.is_collect != 0" @click="loveGoogsConcle()">
					</view>
					<view class="text" v-if="goodsInfo.is_collect == 0" @click="loveGoogs()">
						收藏
					</view>
					<view class="text" v-if="goodsInfo.is_collect != 0" @click="loveGoogsConcle()">
						已收藏
					</view>
				</view>
				<view class="item" @click="shoppingTo()">
					<view class="iconfont icon-gouwuche1">
						<text class="num" v-if="parseFloat(cartnum) > 0">{{
							  cartnum || 0
							}}</text>
					</view>
					<view class="text">
						购物车
					</view>
				</view>
				<!-- @click="toChat()" -->
				<view class="item">
					<button open-type="contact" class="button">
						<view class="iconfont icon-kefu"></view>
						<view class="text">
							客服
						</view>
					</button>
				</view>
			</view>

			<view style="display: flex;flex-wrap: nowrap;" class="bnt">
				<button style="border-radius: 50rpx 0 0 50rpx;background-color: #FE960F;" class="bnts"
					@click="addBuyCar()">
					加入购物车
				</button>
				<button style="border-radius: 0 25px 25px 0;background-color:rgba(233,51,35,1);" class="bnts"
					@click="currentBuy()">
					立即购买
				</button>
			</view>
		</view>

		<view class="two_icon">
			<view class="acea-row row-center-wrapper cartf iconfont icon-shouye3" @click="toIndex"></view>
			<!-- <view class="acea-row row-center-wrapper cartf iconfont icon-sousuo1" @click="toSearch"></view>-->
		</view>

		<!-- 批量购买配件-->
		<u-popup :show="group_buy_show" @close="group_buy_close" :round="8" :safeAreaInsetTop="true">
			<view class="mode-select-box">
				<view class="mode-select">
					<view class="mode-name  mode-name-group ">
						<!-- 规格型号 -->
						配件
					</view>
					<scroll-view scroll-y="true" style="height: 650rpx;background-color: #F2F3F5;"
						@scrolltolower="addGoodLink2" lower-threshold='20px'>
						<view v-for="(value,i) in goods_link_2" :key="i">
							<view class="goods-attr-box">
								<view class="left">
									<image class="img" :src="value.thumb_url" mode=""
										@click="PreviewAttrImage(value.thumb_url)"></image>
								</view>
								<view class="moddle">
									<view class="attr-name">
										{{value.goods_name}}
									</view>
									<view class="price" v-if="attr_value!= null || attr_value.length > 0">
										规格：{{value.attr_value}}
									</view>
									<view class="price">
										库存：{{value.goods_number}}
									</view>
									<view class="price price2 ">
										<text class="txt" v-if="!isLogin">
											￥{{value.shop_price}}
										</text>
										<text v-if="value.vip_price != null && isLogin">
											VIP￥{{value.vip_price}}
										</text>
									</view>
								</view>
								<view class="right">
									<view class="icon" @click="reduceNumberGoodsGroup(i)" v-if="value.buy_number > 0 ">
										<image class="img" :src="ima_url+'/statics/yilangmp/jian.png'" mode=""></image>
									</view>
									<view class="icon" v-if="value.buy_number == 0 ">
										<image class="img" :src="ima_url+'/statics/yilangmp/jian2.png'" mode=""></image>
									</view>
									<view class="input-box">
										<input class="input" type="number" :value="value.buy_number"
											@click="attr_index=i" @input="goodsNumberGoodsGroup"
											@blur="goodsNumberGoodsGroupConfirm" />
									</view>
									<view class="icon  icon2 " @click="addNumberGoodsGroup(i)">
										<image class="img" :src="ima_url+'/statics/yilangmp/jia.png'" mode=""></image>
									</view>
								</view>
							</view>
						</view>
						<view style="width: 100%; text-align: center;padding-top: 30rpx;">
							{{massage_group}}
						</view>

					</scroll-view>
					<view class="goods-price-box">
						<text class="txt1">已选商品{{group_buy_number}}个</text>
					</view>
					<view class="bottom">
						<view class="left" @click="group_buy_show = false">
							取消
						</view>
						<view class="right" @click="goodsGroupBuyConfirm()">
							加入购物车
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!--无规格 加入购物车 -->
		<u-popup :show="add_not_attr_cart_show" @close="add_not_attr_cart_show = false" :round="8"
			:safeAreaInsetTop="true" :closeable="true">
			<view class="mode-select-box">
				<view class="mode-select">
					<view class="img">
						<image :src="goods_thumb" @click="PreviewAttrImage(goods_thumb)">
						</image>
						<view class="img-txt">
							<view class="name">
								{{goods_name}}
							</view>
							<view class="price" v-if="!isLogin">
								￥{{shop_price}}
							</view>
							<view class="price" v-if="isLogin">
								VIP￥{{vip_price}}
							</view>

							<view class="number">
								库存{{product_number}}
							</view>
						</view>
					</view>
					<view class="mode-name" v-if="goodsInfo.goods_attr&&goodsInfo.goods_attr.length>0">
						规格型号
					</view>
					<scroll-view scroll-y="true" style="height: 450rpx;"
						v-if="goodsInfo.goods_attr&&goodsInfo.goods_attr.length>0">
						<radio-group @change="modeSelect">
							<view v-for="(value,i) in goodsInfo.goods_attr" :key="i">
								<view style="margin: 15rpx 20rpx; ">
									<radio @click="radioSelet(i)" :value="value.goods_attr"
										:checked="mode_id == value.goods_attr" />
									<text v-if="value.attr_value != null">{{value.attr_value}} </text>
								</view>
							</view>
						</radio-group>
					</scroll-view>
					<view class="shopping-goods-str">
						<view class="input">
							<view class="left">
								购买数量
							</view>
							<view class="right">
								<view class="number2">
									<u-number-box v-model="buy_number" :positive-integer="true" :input-height="46"
										:input-width="50" :min="1" @blur="goodsNumber" @minus="reduceNumber()"
										@plus="addNumber()">
									</u-number-box>
								</view>
							</view>
						</view>
					</view>

					<view class="bottom">
						<view class="left" @click="shoppingModeConcel()">
							取消
						</view>
						<view class="right" @click="shoppingModeConfirm()">
							加入购物车
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!--多规格规格 加入购物车-->
		<u-popup :show="add_attr_cart_show" @close="add_attr_cart_show = false" :round="8" :safeAreaInsetTop="true">
			<view class="mode-select-box">
				<view class="mode-select">
					<view class="img">
						<image :src="goods_thumb" @click="PreviewAttrImage(goods_thumb)">
						</image>
						<view class="img-txt">
							<view class="name">
								{{goods_name}}
							</view>
							<view class="price" v-if="!isLogin">
								￥{{shop_price}}
							</view>
							<view class="price" v-if="isLogin">
								VIP￥{{vip_price}}
							</view>
						</view>
					</view>
					<view class="mode-name">
						规格型号
					</view>
					<scroll-view scroll-y="true" style="height: 450rpx;background-color: #F2F3F5;">
						<view v-for="(value,i) in attr_list" :key="i">
							<view class="goods-attr-box">
								<view class="left">
									<image class="img" :src="value.attr_img" mode=""
										@click="PreviewAttrImage(value.attr_img)"></image>
								</view>
								<view class="moddle">
									<view class="attr-name">
										{{value.attr_value}}
									</view>
									<view class="price">
										库存：{{value.product_number}}
									</view>
									<view class="price price2 ">
										<text class="txt" v-if="!isLogin">
											￥{{value.shop_price}}
										</text>
										<text v-if="isLogin">
											VIP￥{{value.vip_price}}
										</text>
									</view>
								</view>
								<view class="right">
									<u-number-box :index="value.id" v-model="value.buy_number" :positive-integer="true"
										:input-height="46" :input-width="50" :min="0" @blur="goodsNumberAttr"
										@minus="reduceNumberAttr(i)" @plus="addNumberAttr(i)"></u-number-box>
								</view>
							</view>
						</view>
					</scroll-view>
					<view class="goods-price-box">
						<text class="txt1">已选商品{{attr_buy_number}}个</text>
					</view>
					<view class="bottom">
						<view class="left" @click="shoppingModeConcel4()">
							取消
						</view>
						<view class="right" @click="shoppingModeConfirm4()">
							加入购物车
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!--没有规格情况下 立即购买-->
		<u-popup :show="not_attr_buy_show" @close="not_attr_buy_show = false" :round="8" :safeAreaInsetTop="true"
			:closeable="true">
			<view class="mode-select-box">
				<view class="mode-select">
					<view class="img">
						<image :src="goods_thumb" @click="PreviewAttrImage(goods_thumb)">
						</image>
						<view class="img-txt">
							<view class="name">
								{{goodsInfo.goods_name}}
							</view>
							<view class="price" v-if="!isLogin">
								￥{{shop_price}}
							</view>
							<view class="price" v-if="isLogin">
								VIP￥{{vip_price}}
							</view>
						</view>
					</view>
					<view class="mode-name" v-if="goodsInfo.goods_attr && goodsInfo.goods_attr.length>0">
						规格型号
					</view>
					<scroll-view scroll-y="true" style="height: 250rpx;"
						v-if="goodsInfo.goods_attr && goodsInfo.goods_attr.length>0">
						<radio-group @change="modeSelect">
							<view v-for="(value,i) in goodsInfo.goods_attr" :key="i">
								<view style="margin: 15rpx 20rpx; ">
									<radio @click="radioSelet(i)" :value="value.goods_attr"
										:checked="mode_id == value.goods_attr" />
									<text v-if="value.attr_value != null">{{value.attr_value}} </text>
								</view>
							</view>
						</radio-group>
					</scroll-view>
					<view class="shopping-goods-str">
						<view class="input">
							<view class="left">
								购买数量
							</view>
							<view class="right">
								<u-number-box v-model="buy_number" :positive-integer="true" :input-height="46"
									:input-width="50" :min="0" @blur="goodsNumber" @minus="reduceNumber()"
									@plus="addNumber()">
								</u-number-box>
							</view>
						</view>
					</view>

					<view class="bottom">
						<view class="left" @click="shoppingModeConcel_2()">
							取消
						</view>
						<view class="right" @click="shoppingModeConfirm_2()">
							立即购买
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!-- 多规格情况下 立即购买-->
		<u-popup :show="attr_buy_show" @close="attr_buy_show = false" :round="8" :safeAreaInsetTop="true">
			<view class="mode-select-box">
				<view class="mode-select">
					<view class="img">
						<image :src="goods_thumb" @click="PreviewAttrImage(goods_thumb)">
						</image>
						<view class="img-txt">
							<view class="name">
								{{goodsInfo.goods_name}}
							</view>
							<view class="price" v-if="!isLogin">
								￥{{shop_price}}
							</view>
							<view class="price" v-if="isLogin">
								VIP￥{{vip_price}}
							</view>
						</view>
					</view>
					<view class="mode-name">
						规格型号
					</view>
					<scroll-view scroll-y="true" style="height: 450rpx;background-color: #F2F3F5;">
						<view v-for="(value,i) in attr_list" :key="i">
							<view class="goods-attr-box">
								<view class="left">
									<image class="img" :src="value.attr_img" mode=""
										@click="PreviewAttrImage(value.attr_img)"></image>
								</view>
								<view class="moddle">
									<view class="attr-name">
										{{value.attr_value}}
									</view>
									<view class="price">
										库存：{{value.product_number}}
									</view>
									<view class="price price2 ">
										<text class="txt">
											￥{{value.shop_price}}
										</text>
										<text>
											VIP￥{{value.vip_price}}
										</text>
									</view>
								</view>
								<view class="right">
									<u-number-box :index="value.id" v-model="value.buy_number" :positive-integer="true"
										:input-height="46" :input-width="50" :min="0" @blur="goodsNumberAttr"
										@minus="reduceNumberAttr(i)" @plus="addNumberAttr(i)"></u-number-box>
								</view>
							</view>
						</view>
					</scroll-view>
					<view class="goods-price-box">
						<text class="txt1">已选商品{{attr_buy_number}}个</text>
					</view>
					<view class="bottom">
						<view class="left" @click="shoppingModeConcel_2()">
							取消
						</view>
						<view class="right" @click="shoppingModeConfirm_2()">
							立即购买
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<u-popup :show="share_show" @close="share_show = false" :closeable="true" :round="8" :safeAreaInsetTop="true">
			<view class="padding10 acea-row row-around row-middle">
				<view>
					<button class="btn-box" open-type="share" hover-class="none">
						<image style="width: 100rpx;height: 100rpx;"
							:src="ima_url+'/static/Applets/static/wechatfriend.png' " mode=""></image>
						<view style="text-align: center;" class="fs-14">
							微信
						</view>
					</button>
				</view>
				<view @click="posterGet()">
					<image style="width: 100rpx;height: 100rpx;"
						:src="ima_url+ '/static/Applets/static/images/haibao.png' " mode=""></image>
					<view style="text-align: center;" class="fs-14">
						海报
					</view>
				</view>
			</view>
		</u-popup>

		<u-popup :show="kefu_show" @close="kefu_close" :round="8" :safeAreaInsetTop="true">
			<view class="padding20">
				<u-radio-group v-model="kefu_id" @change="kefuGroupChange" placement="column">
					<u-radio :customStyle="{marginBottom: '8px',padding: '10px'}" v-for="(item, index) in kefu_list"
						:key="index" :label="item.username" :name="item.id">
					</u-radio>
				</u-radio-group>
				<view class="pad30">
					<u-button text="确定" @click="kefu_confirm" type="primary"></u-button>
				</view>
			</view>
		</u-popup>

	</view>
</template>

<script>
	let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	import {
		BASE_URL
	} from '@/config/app'
	import {
		goods_info,
		cart_add,
		cart_number,
		goods_poster,
		del_collect_goods,
		goods_link,
		goods_group,
		supplier_kefu,
		add_sale_goods
	} from "@/api/store.js";
	import {
		userInfo,
		add_scan_log,
		add_collect_shop,
		add_collect_goods
	} from "@/api/user.js";
	import {
		wxa,
		recommend
	} from '@/api/public.js'
	import {
		mapGetters
	} from "vuex";
	import {
		toLogin
	} from '@/libs/login';
	const common = require('@/mixins/common');
	var options = {};
	common(options);
	export default {
		mixins: [{
			methods: options
		}],
		components: {

		},
		data() {
			return {
				sek_loading: true,
				navH: '',
				theme_color: getApp().globalData.theme_color,
				current: 0,
				goodsInfo: {
					goods_name: ''
				},

				product_number: 0,
				goods_id: '',

				mode: '',
				mode_index: 0,
				mode_current: 0,

				is_select_show: false,
				mode_id: '0', //规格id
				supplier_id: '', //店铺id
				shop_price: '', //售价
				vip_price: '', //VIP价格

				product_sn: '0', //规格货号id
				product_sn_2: '', //规格货号				
				attr_value: '', // 规格名称
				buy_number: 1, //购买数量
				goods_number: 1, //立即购买数量
				shopping_isShow: false, //加入购物车模块
				shopping_isShow_2: false, //立即购买模块

				goods_thumb: '', //规格选择时对应的图片 
				ima_url: BASE_URL,

				img_gallery: [],

				share_show: false, //展示自定义分享选择

				poster_img: '', //海报地址
				qrcode: '', //海报地址的二进制部分
				gif_isShow: false,

				// 多规格
				attr_list: [],
				attr_buy_number: 0,
				attr_buy_moner: 0.00,
				attr_index: 0,

				cartnum: 0,

				attr_number: 0,
				getattr_page: 1,
				mode_select_isShow6: false,
				goods_name: '',

				showTip: false,

				goods_link: [], //关联商品
				goods_link_2: [], //关联配件
				goods_group_isShow: false, //半段是否展示配件批量购买
				group_buy_number: 0,
				massage_group: '上拉加载更多...',

				kefu_show: false,
				kefu_list: [],
				kefu_id: '',
				kefu_name: '',

				group_buy_show: false,
				add_not_attr_cart_show: false,
				add_attr_cart_show: false,
				not_attr_buy_show: false,
				attr_buy_show: false
			}
		},
		computed: mapGetters(["isLogin", "app_token", "user_id"]),
		onLoad(e) {
			var _this = this;
			_this.navH = getApp().globalData.navHeight / 2;
			if (e.scene != null) {

				let obj = _this.$util.getUrlParams(decodeURIComponent(e.scene), ',');

				if (parseInt(obj.sid) > 0) {
					console.log('海报分享--分销商品详情---推荐人id----:', obj.sid)
					//存储分享人user_id
					getApp().globalData.parent_id = parseInt(obj.sid)
					_this.$Cache.set('PARENT_ID', parseInt(obj.sid));
					_this.$store.commit("UPDATE_PARENT_ID", parseInt(obj.sid))
				}

				this.goods_id = obj.gid;

				_this.getGoodsInfo()


				// 添加浏览记录
				if (_this.isLogin) {
					_this.add_scan_log()
				}

				this.getgoods_link();
				this.getgoods_link_2();

			} else if (e.goods_id != null) {
				_this.goods_id = e.goods_id;


				if (parseInt(e.user_id) > 0) {
					console.log('微信分享--分销商品详情--推荐人id----:', e.user_id)
					getApp().globalData.parent_id = parseInt(e.user_id)
					_this.$Cache.set('PARENT_ID', parseInt(e.user_id));
					_this.$store.commit("UPDATE_PARENT_ID", parseInt(e.user_id))
				}

				if (_this.isLogin) {
					// recommend({
					// 	app_token: _this.app_token,
					// 	parent_id: e.user_id,
					// 	supplier_id: getApp().globalData.supplier_id
					// }).then(res => {
					// 	console.log('微信分享--分销商品详情--绑定推荐人', res.msg)
					// })

				}

				_this.getGoodsInfo()

				// 添加浏览记录
				if (_this.isLogin) {
					_this.add_scan_log()
				}

				this.getgoods_link();
				this.getgoods_link_2();
			} else {
				uni.showModal({
					content: '参数错误',
					showCancel: false
				})
			}

		},
		onShow() {
			if (this.isLogin) {
				this.countCartnum();
			}
		},
		methods: {
			getGoodsInfo() {
				var _this = this
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				goods_info({
					goods_id: _this.goods_id,
					app_token: _this.app_token
				}).then((res2) => {

					if (res2.status == -1) {
						uni.$u.toast(res2.msg)
						setTimeout(() => {
							uni.navigateBack()
						}, 2000)
					}

					_this.goodsInfo = res2.data;

					for (let value of _this.goodsInfo.img_gallery) {
						_this.img_gallery.push(value.img_url);

					}

					if (_this.goodsInfo.goods_attr.length == 0) {
						_this.showTip = false;
						_this.product_number = _this.goodsInfo.goods_number;
						_this.shop_price = _this.goodsInfo.shop_price;
						_this.vip_price = _this.goodsInfo.vip_price;


						if (_this.goodsInfo.img_gallery.length != 0) {
							_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
						}

					} else if (_this.goodsInfo.goods_attr == null) {
						_this.showTip = false;
						_this.product_number = _this.goodsInfo.goods_number;
						_this.shop_price = _this.goodsInfo.shop_price;

						_this.vip_price = _this.goodsInfo.vip_price;


						if (_this.goodsInfo.img_gallery.length != 0) {
							_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
						}

					} else if (_this.goodsInfo.goods_attr.length == 1) {
						_this.showTip = true;
						_this.is_select_show = true;

						// goods_attr
						_this.mode = _this.goodsInfo.goods_attr[0].attr_value;
						_this.product_number = _this.goodsInfo.goods_attr[0].product_number;
						_this.shop_price = _this.goodsInfo.goods_attr[0].shop_price;
						_this.vip_price = _this.goodsInfo.goods_attr[0].vip_price;

						// 货号id
						_this.product_sn = _this.goodsInfo.goods_attr[0].product_id;
						// 货号product_sn
						_this.product_sn_2 = _this.goodsInfo.goods_attr[0].product_sn;
						// 规格名称
						_this.attr_value = _this.goodsInfo.goods_attr[0].attr_value;
						_this.goods_thumb = _this.goodsInfo.goods_attr[0].attr_img;
						var mode_id = _this.goodsInfo.goods_attr[0].goods_attr;
						_this.mode_id = mode_id;

					} else {
						_this.showTip = true;
						//  有多个规格 默认不选择

						if (_this.goodsInfo.img_gallery.length != 0) {
							_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
						}

						_this.product_number = _this.goodsInfo.goods_number;
						_this.shop_price = _this.goodsInfo.shop_price;
						_this.vip_price = _this.goodsInfo.vip_price;
					}

					uni.hideLoading()
					_this.sek_loading = false;
				})
			},
			addUp(id) {
				var that = this;
				if (this.isLogin) {
					add_sale_goods({
						app_token: that.app_token,
						sdg_id: id
					}).then(res => {
						that.$util.Tips({
							title: res.msg
						})
					})
				} else {
					toLogin()
				}

			},
			group_buy_close() {
				this.group_buy_show = false
			},
			kefuGroupChange(n) {
				this.kefu_id = n;
				for (var i = 0; i < this.kefu_list.length; i++) {
					if (this.kefu_list[i].id == this.kefu_id) {
						this.kefu_name = this.kefu_list[i].username;
					}
				}
			},
			toChat() {
				supplier_kefu({
					app_token: this.app_token,
					supplier_id: this.goodsInfo.supplier_id,
					type: 1
				}).then(res => {
					if (res.data.length) {
						// this.kefu_list = res.data;
						// this.kefu_show = true;

						var kefu = res.data[0]

						this.$util.Tips('/pages/chat/chat_supplier/index?supplier_name=' + kefu.username +
							'&supplier_id=' + kefu.id + '&avatar=' + kefu.avatar + '&goodsId=' +
							this.goodsInfo.goods_id)
					} else {
						this.$util.Tips({
							title: '暂无客服在线，请稍后联系'
						})
					}
				})

			},
			kefu_close() {
				this.kefu_show = false;
			},
			kefu_confirm() {
				if (this.kefu_id == '') {
					return this.$util.Tips({
						title: '请选择客服'
					})
				}
				this.$util.Tips('/pages/chat/chat_supplier/index?supplier_name=' + this.kefu_name +
					'&supplier_id=' + this.kefu_id + '&avatar=' + this.goodsInfo.shop_info.shop_logo + '&goodsId=' +
					this
					.goodsInfo.goods_attr[0].goods_id)
			},
			add_scan_log() {
				var that = this;
				add_scan_log({
					goods_id: that.goods_id,
					app_token: that.app_token
				}).then((res) => {

				})
			},
			// #ifdef MP-WEIXIN
			// 小程序分享
			onShareAppMessage: function(res) {
				var that = this;
				this.share_show = false;
				var path = '/pages/goods/detail/index?goods_id=' + this.goods_id +
					'&supplier_id=' + this.goodsInfo.supplier_id + '&supplier_name=' + this.goodsInfo.shop_info
					.shop_name + '&user_id=' + this.user_id
				return {
					title: this.goodsInfo.goods_name,
					path: path,
					imageUrl: this.goodsInfo.img_gallery[0].img_url,
					success: function(res) {},
					fail: function() {},
				};
			},

			// 分享到朋友圈
			onShareTimeline(res) {
				var that = this;
				this.share_show = false;
				var path = '/pages/goods/detail/index=' + this.goods_id + '&supplier_id=' +
					this.goodsInfo.supplier_id + '&supplier_name=' + this.goodsInfo.shop_info.shop_name + '&user_id=' +
					this.user_id
				return {
					title: this.goodsInfo.goods_name,
					path: path,
					imageUrl: this.goodsInfo.img_gallery[0].img_url,
					success: function(res) {},
					fail: function() {},
				}
			},
			// #endif

			// 自定义分享
			shareClick: function() {
				this.share_show = true;
			},

			// 取消自定义选择
			shareConcleClick: function() {
				this.share_show = false;
			},

			// 获取海报
			posterGet: function() {
				var that = this;
				this.share_show = false;
				that.$util.Tips('./painter/index?goods_id=' + that.goods_id)
			},

			// 客服聊天
			messageTo: function() {

			},

			// 取消店铺收藏
			loveStoreConcle: function() {
				var _this = this;
				del_collect_shop({
					id: _this.goodsInfo.is_mark,
					app_token: _this.app_token
				}).then((res2) => {
					uni.showToast({
						title: res2.msg,
						duration: 1000
					})
					goods_info({
						goods_id: _this.goods_id,
						app_token: _this.app_token
					}).then((res) => {

						_this.goodsInfo.is_mark = res.data.is_mark;

					})

				})
			},

			// 收藏店铺
			loveStore: function() {
				var _this = this;
				add_collect_shop({
					supplier_id: _this.goodsInfo.supplier_id,
					app_token: _this.app_token
				}).then((res2) => {
					uni.showToast({
						title: res2.msg,
						duration: 1000
					})
					goods_info({
						goods_id: _this.goods_id,
						app_token: _this.app_token
					}).then((res) => {
						_this.goodsInfo.is_mark = res.data.is_mark;
						for (let value of _this.goodsInfo.img_gallery) {
							_this.img_gallery.push(value.img_url);
						}
					})
				})
			},

			// 取消商品收藏
			loveGoogsConcle: function() {
				var _this = this;
				del_collect_goods({
					rec_id: _this.goodsInfo.is_collect,
					app_token: _this.app_token
				}).then((res2) => {
					_this.$util.Tips({
						title: res2.msg,
					});
					goods_info({
						goods_id: _this.goods_id,
						app_token: _this.app_token
					}).then((res) => {
						_this.goodsInfo.is_collect = res.data.is_collect;
					})
				})
			},

			// 收藏商品
			loveGoogs: function() {
				var _this = this;
				add_collect_goods({
					goods_id: _this.goods_id,
					app_token: _this.app_token
				}).then((res2) => {
					_this.$util.Tips({
						title: res2.msg,
					});
					goods_info({
						goods_id: _this.goods_id,
						app_token: _this.app_token
					}).then((res) => {
						_this.goodsInfo.is_collect = res.data.is_collect;
					})
				})

			},

			// 导航栏
			current0: function() {
				this.current = 0;
			},
			current1: function() {
				this.current = 1;
			},
			current2: function() {
				this.current = 2;
			},

			// 下拉切换
			currentSwiper: function() {
				this.current = 0;
			},

			// 上拉切换
			currentSwiperower: function() {
				this.current = 1;
			},

			// 轮播
			swiperChangeItem: function(e) {
				this.current = e.detail.current;
			},
			//轮播图预览图片
			previewImage: function(e) {
				var current = e.target.dataset.src
				uni.previewImage({
					current: current,
					urls: this.img_gallery
				})
			},

			//型号选择   添加购物车 和 立即购买时是否选择了型号
			radioSelet: function(index) {
				this.is_select_show = true;
				var _this = this
				this.mode_index = index;
				this.goods_thumb = this.goodsInfo.goods_attr[this.mode_index].attr_img;
				this.product_number = this.goodsInfo.goods_attr[this.mode_index].product_number;
				this.shop_price = this.goodsInfo.goods_attr[this.mode_index].shop_price;
				this.vip_price = this.goodsInfo.goods_attr[this.mode_index].vip_price;
			},

			// 规格选择
			modeSelect: function(e) {
				var goods_attr = e.detail.value;
			},

			// 跳转到店铺首页
			stroreTo: function() {
				this.supplier_id = this.goodsInfo.supplier_id;
				uni.navigateTo({
					url: '/pages/store/index?supplier_id=' + this.supplier_id
				})
			},
			// 跳转到购物车
			shoppingTo: function() {
				uni.switchTab({
					url: '/pages/cart/index'
				})
			},

			showMode: function() {
				uni.showToast({
					title: '该商品无规格',
					icon: 'none'
				})
			},
			// 显示添加购物车模块
			addBuyCar: function() {
				var _this = this;
				_this.goods_name = _this.goodsInfo.goods_name
				this.buy_number = 1;
				if (_this.isLogin) {
					if (this.goodsInfo.goods_attr.length != 0) {

						this.add_attr_cart_show = true
						_this.attr_list = [];
						_this.attr_buy_number = 0;
						_this.attr_buy_moner = 0.00;
						for (let value in _this.goodsInfo.goods_attr) {
							const attr_onj = {
								attr_img: _this.goodsInfo.goods_attr[value].attr_img,
								attr_value: _this.goodsInfo.goods_attr[value].attr_value,
								goods_attr: _this.goodsInfo.goods_attr[value].goods_attr,
								goods_id: _this.goodsInfo.goods_attr[value].goods_id,
								product_id: _this.goodsInfo.goods_attr[value].product_id,
								product_number: _this.goodsInfo.goods_attr[value].product_number,
								product_sn: _this.goodsInfo.goods_attr[value].product_sn,
								shop_price: _this.goodsInfo.goods_attr[value].shop_price,
								vip_price: _this.goodsInfo.goods_attr[value].vip_price,
								buy_number: 0 //多规格对应购买数量
							}
							_this.attr_list.push(attr_onj)
						}

					} else {
						// 无规格
						this.add_not_attr_cart_show = true
					}

					// 判断是否已经选择的规格
					if (this.is_select_show == true) {

						for (let value of this.goodsInfo.goods_attr) {
							if (this.mode_id == value.goods_attr) {
								this.product_number = value.product_number;
								this.shop_price = value.shop_price;
								this.vip_price = value.vip_price;
								this.goods_thumb = value.attr_img;
								this.is_select_show = true; //已经选择了型号
								break;
							} else {
								if (_this.goodsInfo.img_gallery.length != 0) {
									_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
								}

								_this.product_number = _this.goodsInfo.goods_number;
								_this.shop_price = _this.goodsInfo.shop_price;
								this.vip_price = _this.goodsInfo.vip_price;
							}
						}
					} else {

						if (_this.goodsInfo.img_gallery.length != 0) {
							_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
						}

						_this.product_number = _this.goodsInfo.goods_number;
						_this.shop_price = _this.goodsInfo.shop_price;
						this.vip_price = _this.goodsInfo.vip_price;
					}
				} else {
					toLogin('', '/pages/goods/detail/index?goods_id=' + this.goods_id);
				}
			},


			// 多规格减少商品数量
			reduceNumberAttr: function(i) {
				if (this.attr_list[i].buy_number <= 0) {} else {
					this.attr_list[i].buy_number = this.attr_list[i].buy_number - 1;
				}
				this.attr_buy_number = 0;
				this.attr_buy_moner = 0.00;
				for (let value of this.attr_list) {
					this.attr_buy_number = this.attr_buy_number + value.buy_number;
				}
			},
			// 多规格添加商品数量
			addNumberAttr: function(i) {
				this.$set(this.attr_list[i], 'buy_number', parseInt(this.attr_list[i].buy_number) + 1)
				this.attr_buy_number = 0;
				this.attr_buy_moner = 0.00;
				for (let value of this.attr_list) {
					this.attr_buy_number = this.attr_buy_number + value.buy_number;
				}
			},
			// 多规格输入商品数量
			goodsNumberAttr: function(e) {
				this.attr_list[this.attr_index].buy_number = parseInt(e.value);
				this.attr_buy_number = 0;
				this.attr_buy_moner = 0.00;
				for (let value of this.attr_list) {
					this.attr_buy_number = this.attr_buy_number + value.buy_number;
				}
			},

			// 多规格选择确定加入购物车4
			shoppingModeConfirm4: function() {
				var _this = this;
				if (this.attr_buy_number > 0) {
					var conut = 0;
					for (let value of this.attr_list) {

						if (value.buy_number > 0) {

							conut = conut + value.buy_number;

							var goods_id = value.goods_id; //goods_id

							var buy_number = value.buy_number;
							// goods_attr
							var mode = value.attr_value;

							// 货号id
							var product_sn = value.product_id;
							// 货号
							var product_sn_2 = value.product_sn;
							// 规格名称
							var attr_value = value.attr_value;

							// 规格id
							var mode_id = value.goods_attr;
							// 选中的规格

							cart_add({
								app_token: _this.app_token,
								goods_id: goods_id,
								product_id: product_sn, //货号id 无规格为0
								goods_attr_id: mode_id,
								goods_number: buy_number,
							}).then((res) => {
								if (res.status == 1) {
									if (conut == _this.attr_buy_number) {
										uni.showToast({
											title: '添加购物车' + res.msg,
											duration: 1000
										});

										this.add_attr_cart_show = false
										this.countCartnum();
									}
								}
							})
						}
					}
				} else {
					uni.showToast({
						title: '请选择规格数量',
						duration: 1500
					})
				}
			},

			// 取消多规格选择确定加入购物车 4
			shoppingModeConcel4: function() {
				this.add_attr_cart_show = false
				this.not_attr_buy_show = false
				this.attr_list = [];
				this.attr_buy_number = 0;
				this.attr_buy_moner = 0.00;
			},

			// 无规格加入购物车数量  
			goodsNumber: function(e) {
				this.buy_number = parseInt(e.detail.value);
			},

			// 无规格加购买数量 加入购物车
			addNumber: function() {
				this.buy_number = this.buy_number + 1;
			},

			// 无规格减购买数量 加入购物车
			reduceNumber: function() {
				if (this.buy_number <= 1) {

				} else {
					this.buy_number = this.buy_number - 1;
				}
			},

			// 无规格取消加入购物车
			shoppingModeConcel: function() {
				var _this = this;
				this.add_attr_cart_show = false
				this.add_not_attr_cart_show = false
				this.buy_number = '1';
				var acconut = 0;
				for (let value of this.goodsInfo.goods_attr) {
					acconut++;
					if (this.mode_id == value.goods_attr) {
						this.mode_index = acconut - 1;
						this.product_number = value.product_number;
						this.shop_price = value.shop_price;
						this.vip_price = value.vip_price;
						this.goods_thumb = value.attr_img;
						this.is_select_show = true; //已经选择了型号
						break;
					} else {
						this.is_select_show = false;

						if (_this.goodsInfo.img_gallery.length != 0) {
							_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
						}

						_this.product_number = _this.goodsInfo.goods_number;
						_this.shop_price = _this.goodsInfo.shop_price;
						this.vip_price = _this.goodsInfo.vip_price;

					}

				}

			},
			// 确定加入购物车
			shoppingModeConfirm: function() {
				var _this = this;

				if (this.goodsInfo.goods_attr.length == 0 || this.goodsInfo.goods_attr == null) {
					cart_add({
						app_token: _this.app_token,
						goods_id: _this.goodsInfo.goods_id,
						product_id: _this.product_sn,
						goods_attr_id: _this.mode_id,
						goods_number: _this.buy_number,
					}).then((res2) => {
						var data_string = res2;
						_this.$util.Tips({
							title: '添加购物车' + res2.msg,
							icon: 'success',
							duration: 1500
						});
						this.add_not_attr_cart_show = false
						this.countCartnum()

						_this.buy_number = 1;
						var acconut = 0;
						for (let value of _this.goodsInfo.goods_attr) {
							acconut++;
							if (_this.mode_id == value.goods_attr) {
								_this.mode_index = acconut - 1;
								break;
							}

						}

					})

				} else {

					if (this.is_select_show == true) {

						// goods_attr
						this.mode = this.goodsInfo.goods_attr[this.mode_index].attr_value;
						this.product_number = this.goodsInfo.goods_attr[this.mode_index].product_number;
						this.shop_price = this.goodsInfo.goods_attr[this.mode_index].shop_price;
						this.vip_price = this.goodsInfo.goods_attr[this.mode_index].vip_price;

						// 货号id
						this.product_sn = this.goodsInfo.goods_attr[this.mode_index].product_id;
						// 货号
						this.product_sn_2 = _this.goodsInfo.goods_attr[this.mode_index].product_sn;
						// 规格名称
						this.attr_value = _this.goodsInfo.goods_attr[this.mode_index].attr_value;

						// 规格id
						var mode_id = this.goodsInfo.goods_attr[this.mode_index].goods_attr;
						// 选中的规格
						this.mode_id = mode_id;

						// 加入购物车
						cart_add({
							app_token: _this.app_token,
							goods_id: _this.goodsInfo.goods_id,
							product_id: _this.product_sn, //货号id 无规格为0
							goods_attr_id: _this.mode_id,
							goods_number: _this.buy_number,
						}).then((res2) => {
							_this.$util.Tips({
								title: '添加购物车' + res2.msg,
								duration: 1500
							});
							this.add_not_attr_cart_show = false

							this.countCartnum()
							_this.buy_number = 1;
							var acconut = 0;
							for (let value of _this.goodsInfo.goods_attr) {
								acconut++;
								if (_this.mode_id == value.goods_attr) {
									_this.mode_index = acconut - 1;
									break;
								} else {
									if (_this.goodsInfo.img_gallery.length != 0) {
										_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
									}
									_this.product_number = _this.goodsInfo.goods_number;
									_this.shop_price = _this.goodsInfo.shop_price;
									this.vip_price = _this.goodsInfo.vip_price;
								}
							}
						})
					} else {
						uni.showToast({
							title: '请先选择商品规格型号',
							duration: 1500
						})
					}
				}
			},

			// 显示立即购买模块
			currentBuy: function() {
				var _this = this;
				this.goods_number = 1;
				if (_this.isLogin) {
					if (this.goodsInfo.goods_attr.length != 0) {
						// 多规格
						this.attr_buy_show = true

						// 多规格处理AA
						_this.attr_list = [];
						_this.attr_buy_number = 0;
						_this.attr_buy_moner = 0.00;
						for (let value in _this.goodsInfo.goods_attr) {
							const attr_onj = {
								attr_img: _this.goodsInfo.goods_attr[value].attr_img,
								attr_value: _this.goodsInfo.goods_attr[value].attr_value,
								goods_attr: _this.goodsInfo.goods_attr[value].goods_attr,
								goods_id: _this.goodsInfo.goods_attr[value].goods_id,
								product_id: _this.goodsInfo.goods_attr[value].product_id,
								product_number: _this.goodsInfo.goods_attr[value].product_number,
								product_sn: _this.goodsInfo.goods_attr[value].product_sn,
								shop_price: _this.goodsInfo.goods_attr[value].shop_price,
								vip_price: _this.goodsInfo.goods_attr[value].vip_price,
								buy_number: 0 //多规格对应购买数量
							}
							_this.attr_list.push(attr_onj)
						}

					} else {
						// 无规格
						this.not_attr_buy_show = true
					}
					// 判断是否已经选择的规格
					if (this.is_select_show == true) {
						for (let value of this.goodsInfo.goods_attr) {
							if (this.mode_id == value.goods_attr) {
								this.product_number = value.product_number;
								this.shop_price = value.shop_price;
								this.vip_price = value.vip_price;
								this.goods_thumb = value.attr_img;
								this.is_select_show = true; //已经选择了型号
								break;
							} else {
								if (_this.goodsInfo.img_gallery.length != 0) {
									_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
								}
								_this.product_number = _this.goodsInfo.goods_number;
								_this.shop_price = _this.goodsInfo.shop_price;
								this.vip_price = _this.goodsInfo.vip_price;
							}
						}
					} else {
						if (_this.goodsInfo.img_gallery.length != 0) {
							_this.goods_thumb = _this.goodsInfo.img_gallery[0].img_url;
						}
						_this.product_number = _this.goodsInfo.goods_number;
						_this.shop_price = _this.goodsInfo.shop_price;
						this.vip_price = _this.goodsInfo.vip_price;
					}

				} else {
					toLogin('', '/pages/goods/detail/index?goods_id=' + this.goods_id);
				}
			},

			//加立即购买数量 加入购物车
			addNumber_2: function() {
				this.goods_number = this.goods_number + 1;
			},
			// 减立即购买数量 加入购物车
			reduceNumber_2: function() {
				if (this.goods_number <= 1) {} else {
					this.goods_number = this.goods_number - 1;
				}
			},

			// 加入立即购买数量
			goodsNumber_2: function(e) {
				if (parseInt(e.detail.value) < 0) {
					this.goods_number = 0;
				} else {
					this.goods_number = parseInt(e.detail.value);
				}
			},
			// 取消立即购买
			shoppingModeConcel_2: function() {
				var _this = this;

				this.goods_number = 1;
				this.not_attr_buy_show = false

				this.attr_buy_show = false

				var acconut = 0;
				for (let value of this.goodsInfo.goods_attr) {
					acconut++;
					if (this.mode_id == value.goods_attr) {
						this.mode_index = acconut - 1;
						this.product_number = value.product_number;
						this.shop_price = value.shop_price;
						this.vip_price = value.vip_price;
						this.goods_thumb = value.attr_img;
						this.is_select_show = true; //已经选择了型号					
						break;
					} else {
						this.is_select_show = false;
						if (this.goodsInfo.img_gallery.length != 0) {
							this.goods_thumb = this.goodsInfo.img_gallery[0].img_url;
						}
						this.product_number = this.goodsInfo.goods_number;
						this.shop_price = this.goodsInfo.shop_price;
						this.vip_price = this.goodsInfo.vip_price;
					}
				}
			},
			// 确定立即购买
			shoppingModeConfirm_2: function() {
				var _this = this;

				if (this.goodsInfo.shop_price == '面议') {
					this.$util.Tips({
						title: '该商品价格为面议,请联系客服'
					})
					return;
				}

				if (this.goodsInfo.goods_attr.length == 0 || this.goodsInfo.goods_attr == null) {
					uni.navigateTo({
						url: '/pages/order/order_confirm/index?goods_id=' + this.goodsInfo.goods_id +
							'&product_sn=' + this.product_sn + '&goods_number=' + this.buy_number + '&is_fx=0'
					})

					this.not_attr_buy_show = false
				} else {
					if (this.attr_buy_number > 0) {

						this.mode = this.goodsInfo.goods_attr[this.mode_index].attr_value;
						this.product_number = this.goodsInfo.goods_attr[this.mode_index].product_number;
						this.shop_price = this.goodsInfo.goods_attr[this.mode_index].shop_price;
						this.vip_price = this.goodsInfo.goods_attr[this.mode_index].vip_price;

						// 货号id
						this.product_sn = this.goodsInfo.goods_attr[this.mode_index].product_id;
						// 货号
						this.product_sn_2 = _this.goodsInfo.goods_attr[this.mode_index].product_sn;
						// 规格名称
						this.attr_value = _this.goodsInfo.goods_attr[this.mode_index].attr_value;

						// 规格id
						var mode_id = this.goodsInfo.goods_attr[this.mode_index].goods_attr;
						// 选中的规格
						this.mode_id = mode_id;

						let product_list = ''

						for (let i in this.attr_list) {
							if (this.attr_list[i].buy_number > 0) {
								product_list += this.attr_list[i].product_id + '_' + this.attr_list[i].buy_number + ','
							}
						}
						let str = product_list.substr(0, product_list.length - 1)
						uni.navigateTo({
							url: '/pages/order/order_confirm/index?goods_id=' + this.goodsInfo
								.goods_id + '&product_list=' + str + '&product_sn=' + this.product_sn +
								'&goods_number=' + this.goods_number + '&is_fx=0'
						})

						this.attr_buy_show = false
					} else {
						uni.showToast({
							title: '请先选择商品规格型号',
							duration: 1500
						})
					}
				}
			},
			PreviewAttrImage(goods_thumb) {
				const arr = []
				arr.push(goods_thumb)
				uni.previewImage({
					current: goods_thumb,
					urls: arr
				})
			},
			countCartnum() {
				cart_number({
					app_token: this.app_token,
					supplier_id: getApp().globalData.supplier_id,
					market_type: 0
				}).then((res) => {
					this.cartnum = res.data;
				})
			},


			// 关联商品
			getgoods_link() {
				goods_link({
					goods_id: this.goods_id,
					page: this.getattr_page
				}).then((res) => {
					this.goods_link = res.data
				})
			},

			//获取关联配件
			getgoods_link_2() {
				var that = this;
				this.goods_link_2 = [];
				this.link_2_page = '1';

				goods_group({
					goods_id: that.goods_id,
					page: that.link_2_page,
					app_token: that.app_token
				}).then((res) => {
					for (let value of res.data) {
						const obj_g = {
							goods_id: value.goods_id, //商品id
							thumb_url: value.thumb_url, //
							goods_attr_id: value.goods_attr_id, //规格id
							attr_value: value.attr_value, //规格名称
							goods_name: value.goods_name, //规格名称
							shop_price: value.shop_price, //价格
							goods_number: value.goods_number, //库存
							product_id: value.product_id, //货号id
							vip_price: value.vip_price,
							buy_number: 0,
						}
						// 处理商品规格id
						if (value.goods_attr_id != null) {
							obj_g.goods_attr_id = value.goods_attr_id;
						} else {
							obj_g.goods_attr_id = '';
						}
						// 处理商品货号id
						if (value.product_id != null) {
							obj_g.goods_attr_id = value.product_id;
						} else {
							obj_g.goods_attr_id = '';
						}
						that.goods_link_2.push(obj_g)
					}
					if (res.data.length >= 10) {
						that.massage_group = '上拉加载更多...'
					} else {
						that.massage_group = '没有更多配件...'
					}
				})
			},

			// 配件批量购买
			goodsGroupBuy() {
				this.group_buy_show = true
				this.group_buy_number = 0;
				this.getgoods_link_2();
			},
			// 减数量
			reduceNumberGoodsGroup(index) {

				if (this.goods_link_2[index].buy_number > 0) {

					this.goods_link_2[index].buy_number = this.goods_link_2[index].buy_number - 1;

					this.group_buy_number = 0;

					for (let value of this.goods_link_2) {
						this.group_buy_number = this.group_buy_number + value.buy_number;
					}

				}

			},
			// 加数量
			addNumberGoodsGroup(index) {
				this.goods_link_2[index].buy_number = this.goods_link_2[index].buy_number + 1;
				this.group_buy_number = 0;
				for (let value of this.goods_link_2) {
					this.group_buy_number = this.group_buy_number + value.buy_number;
				}
			},
			// 输入数量
			goodsNumberGoodsGroup(e) {
				if (parseInt(e.detail.value) < 0 || e.detail.value == "") {} else {
					this.goods_link_2[index].buy_number = parseInt(e.detail.value);
					this.group_buy_number = 0;
					for (let value of this.goods_link_2) {
						this.group_buy_number = this.group_buy_number + value.buy_number;
					}
				}

			},
			// 确定输入的数量
			goodsNumberGoodsGroupConfirm(e) {
				if (parseInt(e.detail.value) < 0 || e.detail.value == "") {
					uni.showToast({
						title: '数量不能小于0',
						duration: 1500
					})
					this.goods_link_2[index].buy_number = parseInt(e.detail.value);
					this.group_buy_number = 0;
					for (let value of this.goods_link_2) {
						this.group_buy_number = this.group_buy_number + value.buy_number;
					}

				} else {

				}

			},

			// 确定批量购买配件
			goodsGroupBuyConfirm() {
				var _this = this;
				if (this.group_buy_number > 0) {
					var conut = 0;
					for (let value of this.goods_link_2) {
						if (value.buy_number > 0) {
							conut = conut + value.buy_number;
							var goods_id = value.goods_id; //goods_id
							var buy_number = value.buy_number;
							// goods_attr
							var mode = value.attr_value;
							// 货号id
							var product_sn = value.product_id;
							// 货号
							// 规格名称
							var attr_value = value.attr_value;
							// 规格id
							var mode_id = value.goods_attr_id;
							// 选中的规格
							cart_add({
								app_token: _this.app_token,
								goods_id: goods_id,
								product_id: product_sn, //货号id 无规格为0
								goods_attr_id: mode_id,
								goods_number: buy_number,
							}).then((res2) => {
								if (res2.status == 1) {
									if (conut == _this.group_buy_number) {
										uni.showToast({
											title: '添加购物车' + res2.msg,
											duration: 1000
										});

										this.group_buy_show = false
										_this.countCartnum();
									}
								}
							})
						}
					}
				} else {
					uni.showToast({
						title: '请填数量',
						duration: 1500
					})
				}
			},


			togoodsdetails(attr) {
				this.goods_name = attr.goods_name
				var _this = this;
				this.buy_number = 1;
				if (_this.isLogin) {
					// 多规格

					// 多规格处理AA
					_this.attr_list = [];
					_this.attr_buy_number = 0;
					_this.attr_buy_moner = 0.00;
					for (let value in attr.goods_attr) {
						const attr_onj = {
							attr_img: attr.goods_attr[value].attr_img,
							attr_value: attr.goods_attr[value].attr_value,
							goods_attr: attr.goods_attr[value].goods_attr,
							goods_id: attr.goods_attr[value].goods_id,
							product_id: attr.goods_attr[value].product_id,
							product_number: attr.goods_attr[value].product_number,
							product_sn: attr.goods_attr[value].product_sn,
							shop_price: attr.goods_attr[value].shop_price,
							vip_price: attr.goods_attr[value].vip_price,
							buy_number: 0 //多规格对应购买数量
						}
						_this.attr_list.push(attr_onj)
					}


					// 判断是否已经选择的规格
					if (this.is_select_show == true) {

						for (let value of attr.goods_attr) {
							if (this.mode_id == value.goods_attr) {
								this.product_number = value.product_number;
								this.shop_price = value.shop_price;
								this.vip_price = value.vip_price;
								this.goods_thumb = value.attr_img;
								this.is_select_show = true; //已经选择了型号
								break;
							} else {
								if (attr.goods_thumb.length != 0) {
									_this.goods_thumb = attr.goods_thumb;
								}

								_this.product_number = attr.goods_number;
								_this.shop_price = attr.shop_price;
								this.vip_price = attr.vip_price;
							}
						}


					} else {

						if (attr.goods_thumb.length != 0) {
							_this.goods_thumb = attr.goods_thumb;
						}

						_this.product_number = _this.goodsInfo.goods_number;
						_this.shop_price = _this.goodsInfo.shop_price;
						this.vip_price = _this.goodsInfo.vip_price;
					}
				}
			},
			togoodsdetails_1(attr) {
				this.mode_select_isShow8 = true;
				this.goods_thumb = attr.thumb_url
				this.goods_name = attr.goods_name
				this.shop_price = attr.shop_price
				this.vip_price = ''
				this.product_number = ''
				this.attr_name = attr.attr_value

			},
			// 向左滑加载更多关联商品
			addgoodslink() {
				this.getattr_page++
				goods_link({
					goods_id: this.goods_id,
					page: this.getattr_page
				}).then((res) => {
					this.goods_link = [...this.goods_link, ...res.data]
					if (res.data.length == 0) {
						this.$util.Tips({
							title: '暂无更多数据',
							duration: 1500,
						});
					}
				})
			},
			// 向左滑加载更多配件商品
			addGoodLink2() {
				var that = this;
				if (that.massage_group == '正在加载中...') {
					return;
				}
				that.massage_group == '正在加载中...'
				this.link_2_page = (parseInt(this.link_2_page) + 1).toString();

				goods_group({
					goods_id: that.goods_id,
					page: that.link_2_page,
					app_token: that.app_token
				}).then((res) => {
					for (let value of res.data) {
						const obj_g = {
							goods_id: value.goods_id, //商品id
							thumb_url: value.thumb_url, //
							goods_attr_id: value.goods_attr_id, //规格id
							attr_value: value.attr_value, //规格名称
							goods_name: value.goods_name, //规格名称
							shop_price: value.shop_price, //价格
							goods_number: value.goods_number, //库存
							product_id: value.product_id, //货号id
							vip_price: value.vip_price,
							buy_number: 0,
						}

						// 处理商品规格id
						if (value.goods_attr_id != null) {
							obj_g.goods_attr_id = value.goods_attr_id;
						} else {
							obj_g.goods_attr_id = '';
						}
						// 处理商品货号id
						if (value.product_id != null) {

							obj_g.goods_attr_id = value.product_id;

						} else {

							obj_g.goods_attr_id = '';

						}

						that.goods_link_2.push(obj_g)
					}
					if (res.data.length >= 10) {
						that.massage_group = '上拉加载更多...'
					} else {
						that.massage_group = '没有更多配件...'
						if (res.data.length == 0 && parseInt(that.link_2_page) > 1) {
							that.link_2_page = parseInt(that.link_2_page) - 1;
						}
					}
					if (res.data.length == 0) {
						uni.showToast({
							title: '暂无更多配件',
							duration: 1500,
							icon: 'none'
						})
					}
				})
			},
			//关联配件加入购物车
			GoodsGroupAddCard() {
				var _this = this
				// 加入购物车
				cart_add({
					app_token: _this.app_token,
					goods_id: _this.goodsgroup.goods_id,
					product_id: _this.goodsgroup.product_id, //货号id 无规格为0
					goods_attr_id: _this.goodsgroup.goods_attr_id,
					goods_number: _this.buy_number,
				}).then((res2) => {
					var data_string = res2;
					uni.showToast({
						title: '添加购物车' + data_string.msg,
						duration: 1000
					});
					_this.countCartnum()
					_this.mode_select_isShow8 = false;
					_this.buy_number = 1;
				})
			},

			toIndex() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			toSearch() {
				uni.navigateTo({
					url: '../goods_search/goods_search?supplier_id=' + this.goodsInfo.supplier_id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.button {
		background: none !important;
		line-height: inherit;
		padding: 0 !important;
	}

	.button::after {
		border: none !important;
	}

	.page-content {
		.goods-info {
			.goods-box {
				.img-box {
					width: 100%;
					height: 700rpx;

					image {
						width: 100%;
						height: 700rpx;
					}

					video {
						width: 100%;
						height: 700rpx;
					}
				}

				.goods-name {
					padding: 30rpx;

					.txt-price {
						font-size: 18px;
						font-weight: bolder;
						color: #e93323;
						padding-right: 20rpx;
					}

					.txt-unit {
						font-size: 24rpx;
						color: #A1A1A1;
					}

					.txt-old {
						font-size: 24rpx;
						color: #A1A1A1;
						padding-left: 10rpx;
					}

					.txt-oldprice {
						font-size: 24rpx;
						color: #A1A1A1;
						text-decoration: line-through;
						padding-left: 10rpx;
						padding-right: 10rpx;
					}
				}

			}
		}

		.footer {
			flex: 1;
			width: 100%;
			height: 100rpx;
			padding: 0 10rpx;
			position: fixed;
			border-top: 1rpx solid #f0f0f0;
			box-sizing: border-box;
			background-color: #fff;
			height: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
			height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
			bottom: 0;
			/* #ifdef H5 */
			bottom: 0rpx;
			/* #endif */
			/* #ifdef APP-PLUS */
			bottom: 0rpx;
			/* #endif */
			z-index: 40;

			.bnt {
				width: 360rpx;
				height: 76rpx;

				.bnts {
					width: 180rpx;
					text-align: center;
					line-height: 76rpx;
					color: #fff;
					font-size: 28rpx;
				}
			}

			.iconfont {
				text-align: center;
				font-size: 40rpx;
			}

			.icon-gouwuche1 {
				position: relative;

				.num {
					color: #fff;
					position: absolute;
					font-size: 18rpx;
					padding: 2rpx 10rpx 3rpx;
					border-radius: 200rpx;
					top: -10rpx;
					right: -10rpx;
					background-color: rgba(233, 51, 35, 1) !important;
				}
			}

			.icon-shoucang1 {
				color: rgba(233, 51, 35, 1);
			}

			.item {
				display: flex;
				flex-direction: column;
				align-items: center;

				.text {
					text-align: center;
					font-size: 14px;
					font-family: PingFang SC;
				}
			}
		}

		.mode-select-box {
			background-color: rgba($color: #666666, $alpha: 0.5);

			.mode-select {
				width: 100%;
				padding-top: 30rpx;
				background-color: #FFFFFF;

				.bottom {
					position: fixed;
					left: 0;
					right: 0;
					bottom: 0;
					width: 100%;
					height: 100rpx;
					display: flex;
					text-align: center;

					.left {
						flex: 1;
						height: 100rpx;
						line-height: 100rpx;
						background-color: #EEEEEE;
					}

					.right {
						flex: 1;
						height: 100rpx;
						line-height: 100rpx;
						background-color: rgba(233, 51, 35, 1);
						color: #FFFEFF;
					}
				}

				.shopping-goods-str {
					padding: 20px 0;
					width: 100%;
					margin-bottom: 100rpx;

					.radio {
						margin-bottom: 20rpx;
					}

					.input {
						width: 100%;
						display: flex;
						justify-content: flex-end;
						align-items: center;

						.right {
							margin-right: 20rpx;
							margin-left: 20rpx;
						}
					}
				}

				.img {
					width: 100%;
					height: 200rpx;
					display: flex;

					image {
						width: 198rpx;
						height: 198rpx;
						border-radius: 20rpx;
						margin-left: 30rpx;
					}

					.img-txt {
						padding-left: 20rpx;
						font-size: 28rpx;

						.price {
							color: rgba(233, 51, 35, 1);
						}

						.number {
							font-size: 24rpx;
						}

						.name {
							font-size: 28rpx;
						}
					}
				}

				.mode-name {
					width: 100%;
					padding-left: 20rpx;
					margin-top: 20px;
					height: 50rpx;
				}

				.mode-name-group {

					font-size: 35rpx;
					padding-top: 10rpx;
					height: 60rpx;

				}

				.goods-attr-box {
					width: 100%;
					margin-top: 20rpx;
					display: flex;
					margin-top: 10rpx;
					margin-bottom: 10rpx;
					background-color: #FFFFFF;

					.left {
						width: 160rpx;
						height: 150rpx;
						padding-left: 10rpx;
						padding-top: 10rpx;

						.img {
							height: 130rpx;
							width: 130rpx;
						}
					}

					.moddle {
						flex: 1;
						height: 150rpx;
						padding-top: 10rpx;
						padding-bottom: 10rpx;

						.attr-name {
							width: 100%;
							line-height: 30rpx;
							font-size: 28rpx;
							display: -webkit-box;
							word-break: break-all;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
							text-overflow: ellipsis;
						}

						.price {
							width: 100%;
							line-height: 30rpx;
							font-size: 24rpx;
							color: #939393;
							padding-top: 10rpx;

							.txt {
								padding-right: 10rpx;
							}
						}

						.price2 {
							padding-top: 5rpx;
						}
					}

					.right {
						flex: 1;
						height: 150rpx;
						padding-top: 50rpx;
						padding-bottom: 40rpx;
						padding-right: 10rpx;
						display: flex;
						margin: auto;
						justify-content: flex-end;

						.icon {
							width: 50rpx;
							height: 50rpx;
							padding: 15rpx;
							margin-left: 5rpx;
							margin-right: 5rpx;
							background-color: #F2F3F5;

							text-align: center;
							border-top-left-radius: 10rpx;
							border-bottom-left-radius: 10rpx;

							.img {
								width: 20rpx;
								height: 20rpx;
								margin: auto;
							}
						}

						.icon2 {
							border-top-left-radius: 0;
							border-bottom-left-radius: 0;
							border-top-right-radius: 10rpx;
							border-bottom-right-radius: 10rpx;
						}

						.input-box {
							width: 100rpx;
							height: 50rpx;
							background-color: #F2F3F5;

							.input {
								width: 100rpx;
								height: 50rpx;
								line-height: 50rpx;
								text-align: center;
							}
						}
					}
				}

				.goods-price-box {
					width: 100%;
					height: 100rpx;
					line-height: 100rpx;
					padding-left: 20rpx;
					padding-right: 20rpx;

					.txt1 {
						font-size: 24rpx;
						color: #A8A9A9;
						padding-right: 100rpx;
						line-height: 100rpx;
					}

					.txt2 {
						font-size: 26rpx;
						line-height: 100rpx;

					}

					.txt3 {
						font-size: 26rpx;
						line-height: 100rpx;
						color: rgba(233, 51, 35, 1);
					}
				}

			}
		}

		.two_icon {
			position: fixed;
			bottom: 280rpx;
			right: 15rpx;
			display: flex;
			flex-direction: column;
			z-index: 9;

			.cartf {
				margin-top: 10px;
				width: 96rpx;
				height: 96rpx;
				background: #FFFFFF;
				box-shadow: 0 3rpx 16rpx rgba(0, 0, 0, 0.08);
				border-radius: 50%;
				font-size: 47rpx;
				color: #666;
			}
		}


		.product-intro {
			width: 100%;
			padding-bottom: 50px;
			overflow: hidden;

			.title {
				margin-top: 10px;
				color: #333;
				text-align: center;
			}
		}


		.btn-box {
			padding: 0;
			background-color: transparent;
			border: none;
			line-height: inherit;
		}

		.btn-box::after {
			border: none !important;
		}
	}
</style>